<%@ taglib prefix="c" uri="jakarta.tags.core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <base href="<%=request.getContextPath()%>/">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的就诊记录 - 医疗预约系统</title>
    <link rel="stylesheet" href="statics/css/hisStyle.css">
    <style>
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
            padding-bottom: 15px;
            border-bottom: 1px solid #eee;
        }
        .header h1 {
            color: #2c3e50;
            margin: 0;
        }
        .logout-btn {
            background-color: #e74c3c;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            cursor: pointer;
            text-decoration: none;
        }
        .logout-btn:hover {
            background-color: #c0392b;
        }
        .profile-container {
            display: flex;
            gap: 30px;
        }
        .sidebar {
            width: 250px;
            background: white;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        .user-info {
            text-align: center;
            margin-bottom: 20px;
        }
        .avatar {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            object-fit: cover;
            max-width: 100%;
            max-height: 100%;
            margin-bottom: 15px;
            border: 3px solid #3498db;
        }
        .menu-list {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        .menu-item {
            margin-bottom: 5px;
        }
        .menu-link {
            display: block;
            padding: 12px 15px;
            color: #555;
            text-decoration: none;
            border-radius: 5px;
            transition: all 0.3s;
        }
        .menu-link:hover {
            background-color: #f5f5f5;
            color: #3498db;
        }
        .menu-link.active {
            background-color: #3498db;
            color: white;
        }
        .content {
            flex: 1;
            background: white;
            border-radius: 10px;
            padding: 30px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        .content-header {
            margin-bottom: 25px;
        }
        .content-header h2 {
            color: #2c3e50;
            margin: 0;
        }
        .report-card {
            border: 1px solid #eee;
            border-radius: 8px;
            margin-bottom: 20px;
            overflow: hidden;
        }
        .report-header {
            background-color: #f8f9fa;
            padding: 15px 20px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .report-title {
            font-size: 16px;
            font-weight: bold;
            color: #2c3e50;
        }
        .report-date {
            color: #7f8c8d;
            font-size: 14px;
        }
        .report-body {
            padding: 20px;
        }
        .info-row {
            display: flex;
            margin-bottom: 15px;
            padding-bottom: 15px;
            border-bottom: 1px solid #f0f0f0;
        }
        .info-row:last-child {
            border-bottom: none;
            margin-bottom: 0;
            padding-bottom: 0;
        }
        .info-label {
            width: 100px;
            color: #7f8c8d;
            font-weight: bold;
        }
        .info-value {
            flex: 1;
            color: #2c3e50;
        }
        .no-data {
            text-align: center;
            padding: 60px 20px;
            color: #95a5a6;
        }
        .no-data p {
            font-size: 18px;
            margin-bottom: 10px;
        }
        .no-data a {
            color: #3498db;
            text-decoration: none;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>医疗预约系统 - 个人中心</h1>
            <a href="auth/logout" class="logout-btn">退出登录</a>
        </div>

        <div class="profile-container">
            <!-- 侧边菜单 -->
            <div class="sidebar">
                <div class="user-info">
                    <img src="statics/images/adminHead/${loginUser.headpic != null ? loginUser.headpic : 'default.png'}" alt="用户头像" class="avatar">
                    <h3>${loginUser.username}</h3>
                    <p>普通用户</p>
                </div>
                <ul class="menu-list">
                    <li class="menu-item"><a href="frontend/profile" class="menu-link">个人信息</a></li>
                    <li class="menu-item"><a href="frontend/my-appointments" class="menu-link">预约记录</a></li>
                    <li class="menu-item"><a href="frontend/my-reports" class="menu-link active">就诊记录</a></li>
                </ul>
            </div>

            <!-- 主要内容 -->
            <div class="content">
                <div class="content-header">
                    <h2>我的就诊记录</h2>
                </div>

                <c:choose>
                    <c:when test="${not empty reportsList}">
                        <!-- 有就诊记录 -->
                        <c:forEach items="${reportsList}" var="reportMap" varStatus="status">
                            <div class="report-card">
                                <div class="report-header">
                                    <div class="report-title">就诊记录 #${status.index + 1}</div>
                                    <div class="report-date">${reportMap.report.createTime}</div>
                                </div>
                                <div class="report-body">
                                    <div class="info-row">
                                        <div class="info-label">预约编号：</div>
                                        <div class="info-value">${reportMap.appointment.number}</div>
                                    </div>
                                    <div class="info-row">
                                        <div class="info-label">就诊日期：</div>
                                        <div class="info-value">${reportMap.appointment.visit.visitDate}</div>
                                    </div>
                                    <div class="info-row">
                                        <div class="info-label">就诊科室：</div>
                                        <div class="info-value">${reportMap.appointment.visit.department.deptName}</div>
                                    </div>
                                    <div class="info-row">
                                        <div class="info-label">医生姓名：</div>
                                        <div class="info-value">${reportMap.appointment.visit.doctorName}</div>
                                    </div>
                                    <div class="info-row">
                                        <div class="info-label">症状描述：</div>
                                        <div class="info-value">${reportMap.report.symptoms}</div>
                                    </div>
                                    <div class="info-row">
                                        <div class="info-label">医生建议：</div>
                                        <div class="info-value">${reportMap.report.doctorAdvice}</div>
                                    </div>
                                </div>
                            </div>
                        </c:forEach>
                    </c:when>
                    <c:otherwise>
                        <!-- 无就诊记录 -->
                        <div class="no-data">
                            <p>暂无就诊记录</p>
                            <a href="frontend/index">去首页预约</a>
                        </div>
                    </c:otherwise>
                </c:choose>
            </div>
        </div>
    </div>
</body>
</html>